'''----案例：QQ群类----
编写一个QQ群类：
属性：群号、群名、成员、群暗号
方法：显示群号、显示群名、显示群成员、出示群暗号、添加群成员、移除群成员

'''
class QQ_Group:
    def __init__(self,group_num,group_name):
        self.group_num=group_num
        self.group_name=group_name
        self.group_member=list()
        self.__group_signal='123456'
    def show_num(self):
        print(self.group_num)
    def show_name(self):
        print(self.group_name)
    def show_member(self):
        print(self.group_member)
    def display_signal(self):
        tag=0
        ensignal=input('请出示群暗号:')
        if ensignal==self.__group_signal:
            tag=1
        return tag
    def add_member(self):
        tag=self.display_signal()
        if tag==1:
            member=input('请输入新成员名字:')
            self.group_member.append(member)
            print("添加成功")
        else:
            print('暗号错误!!!')
    def remove_member(self):
        tag=self.display_signal()
        if tag==1:
            member = input('请输入要删除的成员名称:')
            for members in self.group_member:
                if member == members:
                    self.group_member.remove(member)
                    break
                else:
                    print('成员不存在!!!!')
        else:
            print("暗号错误!!!")
if __name__ == '__main__':
    qqgroup1=QQ_Group(22637928,'230901千岛湖')
    qqgroup1.show_num()
    qqgroup1.show_member()
    qqgroup1.show_name()
    # qqgroup1.display_signal()
    qqgroup1.add_member()
    qqgroup1.remove_member()
    qqgroup1.show_num()
    qqgroup1.show_member()
    qqgroup1.show_name()
